Stop loading an animation if the first frame is complete. (#350911,
authorMatthias Clasen <mclasen@redhat.com>
Wed, 16 Aug 2006 06:01:09 +0000 (06:01 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 16 Aug 2006 06:01:09 +0000 (06:01 +0000)
2006-08-16  Matthias Clasen  <mclasen@redhat.com>

* gdk-pixbuf-io.c (gdk_pixbuf_new_from_file_at_scale):
Stop loading an animation if the first frame is complete.
(#350911, Christian Neumair)

gdk-pixbuf/ChangeLog
gdk-pixbuf/gdk-pixbuf-io.c

index 275dbb08383829e02ed60d9b02daed72c0dea9c5..2a367c0c09a68cdfc41f35449ce13e6ff53ccbf1 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-16  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk-pixbuf-io.c (gdk_pixbuf_new_from_file_at_scale): 
+       Stop loading an animation if the first frame is complete.
+       (#350911, Christian Neumair)
+
 2006-07-23  Matthias Clasen  <mclasen@redhat.com>
        
        * === Released 2.10.1 ===
index a76f46431a6cef3f5fe47c56d930e518e87e66a1..3476bfed4b3f1658700c7a4ad8e67fa4ff2963f0 100644 (file)
@@ -1095,6 +1095,9 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename,
                gint height;
                gboolean preserve_aspect_ratio;
        } info;
+       GdkPixbufAnimation *animation;
+       GdkPixbufAnimationIter *iter;
+       gboolean has_frame;
 
        g_return_val_if_fail (filename != NULL, NULL);
         g_return_val_if_fail (width > 0 || width == -1, NULL);
@@ -1122,7 +1125,8 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename,
 
        g_signal_connect (loader, "size-prepared", G_CALLBACK (size_prepared_cb), &info);
 
-       while (!feof (f) && !ferror (f)) {
+       has_frame = FALSE;
+       while (!has_frame && !feof (f) && !ferror (f)) {
                length = fread (buffer, 1, sizeof (buffer), f);
                if (length > 0)
                        if (!gdk_pixbuf_loader_write (loader, buffer, length, error)) {
@@ -1131,11 +1135,20 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename,
                                g_object_unref (loader);
                                return NULL;
                        }
+               
+               animation = gdk_pixbuf_loader_get_animation (loader);
+               if (animation) {
+                       iter = gdk_pixbuf_animation_get_iter (animation, 0);
+                       if (!gdk_pixbuf_animation_iter_on_currently_loading_frame (iter)) {
+                               has_frame = TRUE;
+                       }
+                       g_object_unref (iter);
+               }
        }
 
        fclose (f);
 
-       if (!gdk_pixbuf_loader_close (loader, error)) {
+       if (!gdk_pixbuf_loader_close (loader, error) && !has_frame) {
                g_object_unref (loader);
                return NULL;
        }